package opera;

import book.*;
import java.util.Scanner;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: 邓大帅
 * Date: 2022-12-20
 * Time: 10:13
 */
public class FindOperation implements IOperation {
    public void work(BookList bookList) {
        System.out.println("查找图书");
        System.out.println("输入你要查找图书的名字");
        Scanner input = new Scanner(System.in);
        String name = input.nextLine();
        int currentSize = bookList.getUseSize();
        for (int i = 0; i < currentSize; i++) {
            //System.out.println(bookList[i]);
            Book book = bookList.getBook(i);
            if(book.getName().equals(name)) {
                System.out.println("找了这本书：");
                System.out.println(book);
                return;
            }
        }
        System.out.println("没有这本书！");
    }
}
